{% extends 'base.html' %}
{% block title %}代办事项程序{% endblock %}

{% block content %}
  <!-- 导航 navigation -->
    <nav class="navbar navbar-default navbar-inverse">
      <div class="container-fluid">
        <div class="navbar-header">
          <a class="navbar-brand" href="#"><span class="glyphicon glyphicon-th-list"></span> Brand</a>
        </div>
      </div>
    </nav>

  <!-- 添加todo表单 -->
  <div id="todo-add container">
  <form action="{{ url_for('add') }}" method="post" class="form-inline">
    <textarea rows="5" cols="50" placeholder="请输入待办事项" name="content"></textarea>
    <button type="submit" class="btn btn-success btn-lg">添加</button>  <!-- 写法1 -->
{#    <input type="submit" placeholder="添加">#}  <!-- 写法2 -->
  </form>
  </div>

<hr>

  <!-- todo列表 -->
<div id="todo-list">
  <table class="table table-striped">
    <th>
      <td>状态</td>
      <td>内容</td>
      <td>删除</td>
      <td>完成</td>
    </th>
    {% for todo in todo_list %}
    <tr>
    <td>{{ loop.index }}</td>
    {% if todo.status == 0 %}
      <td><span class="glyphicon glyphicon-remove-sign"></span></td>
    {% elif todo.status == 1 %}
      <td><span class="glyphicon glyphicon-ok-sign" style=""></span></td>
    {% endif %}


{#    <td>{{ todo.status }}</td>#}
    <td>{{ todo.content }}</td>
{#    <td><a href="{{ url_for('delete', content=todo.content )}}">X</a></td>#}
      <td><a href="{{ url_for('delete', _id=todo._id )}}"><span class="glyphicon glyphicon-remove"></span></a></td>
      <td><a href="{{ url_for('finish', _id=todo._id) }}"><sapn class="glyphicon glyphicon-ok"></sapn></a></td>
       <!-- todo._id 可以取id -->
    </tr>
    {% endfor %}
  </table>

</div>
{% endblock %}
